package com.anivia.system.auth.enums;

import com.anivia.common.core.enums.BaseEnum;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 权限资源类型
 *
 * @author wangj
 */
@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum ResourceTypeEnum implements BaseEnum {
    /**
     * 菜单
     */
    MENU(1, "菜单"),
    /**
     * 按钮
     */
    BUTTON(2, "按钮");

    @EnumValue
    private Integer code;
    private String desc;


    public String toString() {
        return name() + "-" + getDesc();
    }

    public static ResourceTypeEnum getByCode(Integer code) {
        for (ResourceTypeEnum resourceType : values()) {
            if (resourceType.code.equals(code)) {
                return resourceType;
            }
        }
        return null;
    }
}